home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / PlayerPRO 4.5.8 / PlayerPRO 4.5.8 Dev.Kit / MADH Library 4.5 / MacOS Examples / Exemple.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-10  |  31.0 KB  |  1,340 lines  |  [TEXT/CWIE]

  1. #include "Retrace.h"
  2. #include "Start.h"
  3. #include "Gestalt.h"
  4. #include "Mad.h"
  5. #include "RDriver.h"
  6. #include "sound.h"
  7. #include "EPPC.h"
  8.  
  9. #define    VERSION        0x0454
  10. #define    PLAYERPREF    "\pPlayerPRO Prefs"
  11.  
  12. void DoPreferences2();
  13. void SetDText (DialogPtr dlog, short item, Str255 str);
  14.  
  15.      MADDriverRec    *MADDriver;
  16.  
  17. #if defined(powerc) || defined (__powerc)
  18. #pragma options align = mac68k
  19. #endif
  20.  
  21. typedef struct
  22. {
  23.     short            Version;
  24.     Boolean            Loop;
  25.     Boolean            Stereo;
  26.     Boolean            PPCMachine;
  27.     Boolean         xxxxxxxx;
  28.     Fixed            Frequence;
  29.     Boolean            LargeWindow;
  30.     Boolean            AutoCreator;
  31.     Boolean            MicroRecording;
  32.     short            oldShort;
  33.     Boolean            AffichageDIGI;
  34.     short            NoStart;
  35.     Point            WinPos[ 30];
  36.     short            WinEtat[ 30];
  37.     short            PianoKey[ 300];
  38.     Boolean            oldBool;
  39.     Boolean            InstruListBig;
  40.     Boolean            PatListBig;
  41.     Boolean            AutoScroll;
  42.     short            LoopType;
  43.     short            WinHi[30];
  44.     Boolean            val;
  45.     long            sL;
  46.     Byte            notUsed;
  47.     Str32            name;
  48.     long            sum;
  49.     long            Mz;
  50.     unsigned long    firstStart;
  51.     short            WinLarg[30];
  52.     RGBColor        tracksColor[ 32];
  53.     short            tracksColorID[ 32];
  54.     short            PianoPos;
  55.     short            volumeLevel;
  56.     Boolean            MADCompression;
  57.     Boolean            SSText;
  58.     Boolean            SSStars;
  59.     Boolean            SSJumping;
  60.     Boolean            FText;
  61.     Boolean            FStars;
  62.     Boolean            FBalls;
  63.     short            TextS;
  64.     Boolean            ThreadUse;
  65.     Boolean            FSinScroll;
  66.     Boolean            RememberMusicList;
  67.     Boolean            ddddddddd;
  68.     long            WinID[ 30];
  69.     Boolean            DigitalInstru;
  70.     Boolean            DigitalNote;
  71.     Boolean            DigitalEffect;
  72.     Boolean            DigitalArgu;
  73.     Boolean            DigitalVol;
  74.     Boolean            GoToStop;
  75.     Boolean            DriverEffects[ 20];
  76.     Boolean            MADC;
  77.     short            OscilloSize;
  78.     short            OscilloType;
  79.     short            fileTypeExportSND;
  80.     OSType            CompressionExportSND;
  81.     Boolean            ActiveHelp;
  82.     short            SpectrumSize;
  83.     short            SpectrumType;
  84.     
  85.     /** Driver Settings **/
  86.     
  87.     short            numChn;                                // Active tracks from 2 to 32, automatically setup when a new music is loaded
  88.     short            outPutBits;                            // 8 or 16 Bits
  89.     unsigned long    outPutRate;                            // Fixed number, by example : rate44khz, rate22050hz, rate22khz, rate11khz, rate11025hz
  90.     short            outPutMode;                            // MonoOutPut, StereoOutPut or DeluxeStereoOutPut ?
  91.     short            driverMode;                            // ASCSoundDriver, AWACSoundDriver, MIDISoundDriver or SoundManagerDriver
  92.     Boolean            antiAliasing;                        // Use AntiAliasing filter ?
  93.  
  94.     /** Mozart Prefs **/
  95.  
  96.     Boolean            UseOctaveMarkers;
  97.     Boolean            UseMarkers;
  98.     short            MarkersSize;
  99.     short            MarkersOffSet;
  100.     short            MozartX;
  101.  
  102.     /** News 4.5    **/
  103.     
  104.     Boolean            SpectrumScale;
  105.     Boolean            ClassicalProjection;
  106.     Boolean            PianoOctaveMarkers;
  107.     Boolean            SmallPiano;
  108.     Boolean            FastMusicList;
  109.     long            FastDigitalEdition;
  110.     
  111.     Boolean            MacKeyBoard;
  112.     Boolean            MidiKeyBoard;
  113.     Boolean            QKMidiKeyBoard;
  114.     
  115.     Boolean            MIDIVelocity;
  116.     Boolean            MIDIChanInsTrack;
  117.     
  118.     short            KeyUpMode;
  119.     
  120.     /** News 4.5.1    **/
  121.     
  122.     Boolean            Interpolation;
  123.     Boolean            MicroDelay;
  124.     long            MicroDelaySize;
  125.     Boolean            surround;
  126.  
  127.     /** News 4.5.2    **/
  128.  
  129.     Boolean            OCArrow[ 128];
  130.     short            MozartC1h, MozartC2h;
  131.     OSType            SoundTypeSamp;
  132.     OSType            SoundTypeIns;
  133.     short            LinesHeight;
  134.     Boolean            SaveMusicList;
  135.     short            softVolumeLevel;
  136.     
  137.     Boolean            ADAPremember;
  138.     Boolean            ADAPsave;
  139.     Boolean            ADAPuse;
  140.     
  141.     Boolean            osciTile;
  142.     
  143.     Boolean            addExtension;
  144.     
  145.     Boolean            AutoPlayWhenOpen;
  146.     
  147.     Boolean            Reverb;
  148.     long            ReverbSize;
  149.     long            ReverbStrength;
  150.     
  151.     Boolean            DirectVideo;
  152.  
  153.     /** News 4.5.3 **/
  154.     
  155.     Boolean            TickRemover;
  156.     Boolean            AutomaticOpen;
  157.     Boolean            FinePositioning;
  158.     
  159.     short            ChannelType;
  160.     short            amplitude;
  161.     OSType            Compressor;
  162.     Fixed            FrequenceSpeed;
  163.     
  164.     Boolean            RecordAllTrack;
  165.     
  166. }    Prefs;
  167. #if defined(powerc) || defined (__powerc)
  168. #pragma options align = reset
  169. #endif
  170.  
  171. static     Boolean            Stereo, StereoMixing, NewSoundManager, has16Bit;
  172. static    int                VolumeH, SpeedH;
  173. static    PixPatHandle    workPixPat;
  174.         Prefs            thePrefs;
  175.  
  176.         DialogPtr    myDialog;
  177.  
  178.         Boolean        OnTourne;
  179.  
  180.         
  181. void MegaLoop( void);
  182. void ReadAndPlayMusic( Str255    myFile, OSType    fdType);
  183. void SwitchDriverTo2();
  184.  
  185. #include "Drag.h"
  186.  
  187. #ifndef THINK_C
  188. static    DragTrackingHandlerUPP    MyTrackingUPP;
  189. static    DragReceiveHandlerUPP    MyReceiveUPP;
  190. #endif
  191.  
  192. static    Boolean                    canAcceptDrag;
  193.  
  194. void pStrcat(register unsigned char *s1, register unsigned char *s2)
  195. {
  196.     register unsigned char *p;
  197.     register short len, i;
  198.     
  199.     if (*s1+*s2<=255) 
  200.     {
  201.         p = *s1 + s1 + 1;
  202.         *s1 += (len = *s2++);
  203.     }
  204.     else 
  205.     {
  206.         *s1 = 255;
  207.         p = s1 + 256 - (len = *s2++);
  208.     }
  209.     for (i=len; i; --i) *p++ = *s2++;
  210. }
  211.  
  212. void InitDriverString()
  213. {
  214. Str255    str;
  215.  
  216. if( MADDriver->DriverSettings.Reverb && MADDriver->DriverSettings.outPutMode != MonoOutPut)
  217. {
  218.     NumToString( MADDriver->DriverSettings.ReverbSize, str);
  219.     pStrcat( str, "\pms");
  220.     SetDText( myDialog, 27, str);
  221.     
  222.     NumToString( MADDriver->DriverSettings.ReverbStrength, str);
  223.     pStrcat( str, "\p%");
  224.     SetDText( myDialog, 29, str);
  225. }
  226. else
  227. {
  228.     SetDText( myDialog, 27, "\pOFF");
  229.     
  230.     NumToString( MADDriver->DriverSettings.ReverbStrength, str);
  231.     pStrcat( str, "\p%");
  232.     SetDText( myDialog, 29, str);
  233. }
  234.  
  235. if( MADDriver->DriverSettings.MicroDelay && MADDriver->DriverSettings.outPutMode != MonoOutPut)
  236. {
  237.     NumToString( MADDriver->DriverSettings.MicroDelaySize, str);
  238.     pStrcat( str, "\pms");
  239.     SetDText( myDialog, 7, str);
  240. }
  241. else SetDText( myDialog, 7, "\pDelay OFF");
  242.  
  243. if( MADDriver->DriverSettings.surround && MADDriver->DriverSettings.outPutMode != MonoOutPut) SetDText( myDialog, 24, "\pSurround ON");
  244. else SetDText( myDialog, 24, "\pSurround OFF");
  245.  
  246. if( MADDriver->DriverSettings.Interpolation) SetDText( myDialog, 22, "\pInterpolation ON");
  247. else SetDText( myDialog, 22, "\pInterpolation OFF");
  248.  
  249. if( MADDriver->DriverSettings.TickRemover && MADDriver->DriverSettings.outPutMode != MonoOutPut) SetDText( myDialog, 31, "\pTick Remover ON");
  250. else SetDText( myDialog, 31, "\pTick Remover OFF");
  251.  
  252. switch( MADDriver->DriverSettings.outPutRate)
  253. {
  254.     case rate11khz:    SetDText( myDialog, 10, "\p11 Khz");                    break;
  255.     case rate22khz:    SetDText( myDialog, 10, "\p22 Khz");                    break;
  256.     case rate44khz:    SetDText( myDialog, 10, "\p44 Khz");                    break;
  257. }
  258.  
  259. switch( MADDriver->DriverSettings.outPutMode)
  260. {
  261.     case MonoOutPut:            SetDText( myDialog, 13, "\pMono");            break;
  262.     case StereoOutPut:            SetDText( myDialog, 13, "\pStereo");        break;
  263.     case DeluxeStereoOutPut:    SetDText( myDialog, 13, "\pTrue Stereo");    break;
  264. }
  265. switch( MADDriver->DriverSettings.outPutBits)
  266. {
  267.     case 8:        SetDText( myDialog, 16, "\p8 bits");                        break;
  268.     case 16:    SetDText( myDialog, 16, "\p16 bits");                        break;
  269. }
  270.  
  271. }
  272.  
  273. void FrameRectRelief( Rect *theRect)
  274. {
  275. RGBColor    theColor;
  276.     
  277.     #define GrisClair    0xFFFF
  278.     #define GrisFonce    0x4000
  279.  
  280.     MoveTo( theRect->left, theRect->top);
  281.     
  282.     theColor.red = GrisFonce;    theColor.blue = GrisFonce;    theColor.green = GrisFonce;
  283.     RGBForeColor( &theColor);
  284.     LineTo( theRect->right, theRect->top);
  285.     
  286.     theColor.red = GrisClair;    theColor.blue = GrisClair;    theColor.green = GrisClair;
  287.     RGBForeColor( &theColor);
  288.     LineTo( theRect->right, theRect->bottom);
  289.     
  290.     theColor.red = GrisClair;    theColor.blue = GrisClair;    theColor.green = GrisClair;
  291.     RGBForeColor( &theColor);
  292.     LineTo( theRect->left, theRect->bottom);
  293.     
  294.     theColor.red = GrisFonce;    theColor.blue = GrisFonce;    theColor.green = GrisFonce;
  295.     RGBForeColor( &theColor);
  296.     LineTo( theRect->left, theRect->top);
  297.     
  298.     
  299.     ForeColor( blackColor);
  300. }
  301.  
  302. pascal OSErr MyTrackingTools(short message, WindowPtr theWindow, void *handlerRefCon, DragReference theDrag)
  303. {    short                result;
  304.     unsigned long        attributes;
  305.     ItemReference        theItem;
  306.     RgnHandle            theRgn;
  307.     Point                theMouse, localMouse;
  308.     FlavorFlags         theFlags;
  309.     long                textSize;
  310.     HFSFlavor            myFlavor;
  311.     FInfo                fndrInfo;
  312.     char                str[ 5];
  313.     
  314.     if ((message != dragTrackingEnterHandler) && (!canAcceptDrag)) return( noErr);
  315.  
  316.     SetPort( theWindow);
  317.     
  318.     GetDragAttributes(theDrag, &attributes);
  319.     
  320.     switch (message) {
  321.  
  322.         case dragTrackingEnterHandler:
  323.             canAcceptDrag = false;
  324.             
  325.             GetDragItemReferenceNumber(theDrag, 1, &theItem);
  326.             result = GetFlavorFlags(theDrag, theItem, flavorTypeHFS, &theFlags);
  327.             if (result == noErr)
  328.             {
  329.                 GetFlavorDataSize( theDrag, theItem, flavorTypeHFS, &textSize);
  330.                 
  331.                 GetFlavorData( theDrag, theItem, flavorTypeHFS, &myFlavor, &textSize, 0L);
  332.         
  333.                 HSetVol( 0L, myFlavor.fileSpec.vRefNum, myFlavor.fileSpec.parID);
  334.                 GetFInfo( myFlavor.fileSpec.name, 0, &fndrInfo);
  335.                 
  336.                 
  337.                 OSType2Ptr( fndrInfo.fdType, str);
  338.                 
  339.                 if( MADPlugAvailable( str)) canAcceptDrag = true;
  340.             }
  341.         break;
  342.  
  343.         case dragTrackingEnterWindow:
  344.             
  345.         break;
  346.  
  347.         case dragTrackingInWindow:
  348.             //
  349.             //    We receive InWindow messages as long as the mouse is in one of our windows
  350.             //    during a drag. We draw the window highlighting and blink the insertion caret
  351.             //    when we get these messages.
  352.             //
  353.  
  354.             GetDragMouse(theDrag, &theMouse, 0L);
  355.             localMouse = theMouse;
  356.             GlobalToLocal(&localMouse);
  357.  
  358.             //
  359.             //    Show or hide the window highlighting when the mouse enters or leaves the
  360.             //    TextEdit field in our window (we don't want to show the highlighting when
  361.             //    the mouse is over the window title bar or over the scroll bars).
  362.             //
  363.             
  364.             if( PtInRect( localMouse, &myDialog->portRect))
  365.             {
  366.                 RectRgn(theRgn = NewRgn(), &myDialog->portRect);
  367.                 
  368.                 ShowDragHilite(theDrag, theRgn, true);
  369.                 DisposeRgn(theRgn);
  370.             }
  371.         break;
  372.  
  373.         case dragTrackingLeaveWindow:
  374.             HideDragHilite( theDrag);
  375.         break;
  376.  
  377.         case dragTrackingLeaveHandler:
  378.         
  379.         break;
  380.     }
  381.  
  382.     return(noErr);
  383. }
  384.  
  385. pascal OSErr MyReceiveTools(WindowPtr theWindow, unsigned long handlerRefCon, DragReference theDrag)
  386. {
  387.     HFSFlavor            myFlavor;
  388.     OSErr                result;
  389.     unsigned short        items;
  390.     ItemReference        theItem;
  391.     DragAttributes        attributes;
  392.     Size                textSize;
  393.     short                index, mouseDownModifiers, mouseUpModifiers, moveInstru;
  394.     FInfo                fndrInfo;
  395.     OSErr                err;
  396.     
  397.     SetPort(theWindow);
  398.     
  399.     GetDragAttributes(theDrag, &attributes);
  400.     GetDragModifiers(theDrag, 0L, &mouseDownModifiers, &mouseUpModifiers);
  401.     
  402.     moveInstru = (attributes & dragInsideSenderWindow) &&  (!((mouseDownModifiers & optionKey) | (mouseUpModifiers & optionKey)));
  403.     
  404.     HideDragHilite( theDrag);
  405.  
  406.     //
  407.     //    A file is coming...
  408.     //
  409.     
  410.     CountDragItems(theDrag, &items);
  411.     
  412.     index = 1;        // Take only 1 file
  413.     
  414.     GetDragItemReferenceNumber(theDrag, index, &theItem);
  415.     
  416.     result = GetFlavorDataSize(theDrag, theItem, flavorTypeHFS, &textSize);
  417.     
  418.     if (result == noErr)
  419.     {        
  420.         GetFlavorData(theDrag, theItem, flavorTypeHFS, &myFlavor, &textSize, 0L);
  421.         
  422.         err = HGetFInfo( myFlavor.fileSpec.vRefNum, myFlavor.fileSpec.parID, myFlavor.fileSpec.name, &fndrInfo);
  423.         
  424.         if( err == noErr)
  425.         {
  426.             ReadAndPlayMusic( myFlavor.fileSpec.name, fndrInfo.fdType);
  427.             
  428.             return(noErr);
  429.         }
  430.     }
  431.     
  432.     return(dragNotAcceptedErr);
  433. }
  434.  
  435. void MyDebugStr( Str255    aStr)
  436. {
  437.     DebugStr( aStr);
  438. }
  439.  
  440. void SetDText (DialogPtr dlog, short item, Str255 str)
  441. {
  442. Handle    itemHandle;
  443. short    itemType;
  444. Rect    itemRect;
  445. Str255    myStr;
  446.  
  447.     GetDialogItem (dlog, item, &itemType, &itemHandle, &itemRect);
  448.     if( itemHandle == 0L) MyDebugStr("\pError in SetDText");
  449.     
  450.     GetDialogItemText (itemHandle, myStr);
  451.     if( RelString( myStr, str, true, true) != 0) SetDialogItemText (itemHandle, str);
  452. }
  453.  
  454. void SetUpSize()
  455. {
  456. /*Handle    hRsrc;
  457. long    fileSize;
  458.  
  459.     hRsrc = GetResource( 'SIZE', -1);
  460.     if( hRsrc == 0L) Debugger();
  461.     
  462.     HNoPurge( hRsrc);
  463.     HLock( hRsrc);
  464.     
  465.     fileSize = *((long*)((*hRsrc)+2));
  466.     
  467.     fileSize -= FreeMem();
  468.     fileSize += 20000L;
  469.     
  470.     *((long*)((*hRsrc)+2)) = (long) fileSize;
  471.     *((long*)((*hRsrc)+6)) = (long) fileSize;
  472.     
  473.     ChangedResource( hRsrc);
  474.     WriteResource( hRsrc);
  475.     
  476.     HUnlock( hRsrc);
  477.     HPurge( hRsrc);
  478.     
  479.     ReleaseResource( (Handle) hRsrc);*/
  480. }
  481.  
  482. void    SKVolume( short vol)
  483. {
  484. Point            tempL;
  485. long            *tL;
  486.  
  487.     if(vol>8) vol = 8;
  488.     if(vol<0) vol = 0;
  489.     
  490.     if( vol > 0)
  491.     {
  492.         if( NewSoundManager)
  493.         {
  494.             tempL.v = vol * 32L;
  495.             tempL.h = vol * 32L;
  496.             
  497.             tL = (long*) &tempL;
  498.             SetDefaultOutputVolume( *tL);
  499.         }
  500.         else SetSoundVol( vol - 1);
  501.     }
  502.  
  503. }
  504.  
  505. short PressTypeMenu( short whichMenu, short item)
  506. {
  507.     long        mresult, r;
  508.     Point        Zone;
  509.     short        i, itemType, startitem;
  510.     Handle        itemHandle;
  511.     Rect        itemRect;
  512.     MenuHandle    MenuDriver;
  513.     Str255        str;
  514.  
  515.     MenuDriver = GetMenu( whichMenu);
  516.     
  517.     for( i = 0 ; i < CountMItems( MenuDriver); i++) EnableItem( MenuDriver, i+1);
  518.     
  519.     InsertMenu( MenuDriver, hierMenu);
  520.     
  521.     GetDialogItem( myDialog, item, &itemType, &itemHandle, &itemRect);
  522.     Zone.h = itemRect.left;    Zone.v = itemRect.top;
  523.     
  524.     LocalToGlobal( &Zone);
  525.     
  526.     #define ApFontID    *((short*) 0x984)
  527.     
  528.     i = ApFontID;    ApFontID = 4;
  529.     
  530.     switch( whichMenu)
  531.     {
  532.         case 128:
  533.             if( !Stereo || MADDriver->DriverSettings.outPutMode == MonoOutPut) DisableItem( MenuDriver, 2);
  534.             
  535.             
  536.             if( MADDriver->DriverSettings.surround  && MADDriver->DriverSettings.outPutMode != MonoOutPut) startitem = 2;
  537.             else startitem = 1;
  538.         break;
  539.         
  540.         case 129:
  541.             if( MADDriver->DriverSettings.Interpolation) startitem = 2;
  542.             else startitem = 1;
  543.         break;
  544.         
  545.         case 130:
  546.             if( !Stereo || MADDriver->DriverSettings.outPutMode == MonoOutPut) DisableItem( MenuDriver, 2);
  547.             
  548.             if( MADDriver->DriverSettings.TickRemover) startitem = 2;
  549.             else startitem = 1;
  550.         break;
  551.         
  552.         case 165:
  553.             if( !Stereo || MADDriver->DriverSettings.outPutMode == MonoOutPut)
  554.             {
  555.                 for( i = 1 ; i < CountMItems( MenuDriver); i++) DisableItem( MenuDriver, i+1);
  556.             }
  557.             
  558.             if( MADDriver->DriverSettings.MicroDelay  && MADDriver->DriverSettings.outPutMode != MonoOutPut)
  559.             {
  560.                 startitem = 2;
  561.                 for( i = 1 ; i < CountMItems( MenuDriver); i++)
  562.                 {
  563.                     Str255    str;
  564.                     long    r;
  565.                     
  566.                     GetMenuItemText( MenuDriver, i+1, str);
  567.                     
  568.                     str[ 0] -= 3;    StringToNum( str, &r);    str[ 0] += 3;
  569.                     
  570.                     if( r == MADDriver->DriverSettings.MicroDelaySize) startitem = i+1;
  571.                 }
  572.             }
  573.             else startitem = 1;
  574.         break;
  575.  
  576.         case 170:
  577.             if( !Stereo || MADDriver->DriverSettings.outPutMode == MonoOutPut)
  578.             {
  579.                 for( i = 1 ; i < CountMItems( MenuDriver); i++) DisableItem( MenuDriver, i+1);
  580.             }
  581.             
  582.             if( MADDriver->DriverSettings.Reverb && MADDriver->DriverSettings.outPutMode != MonoOutPut)
  583.             {
  584.                 startitem = 2;
  585.                 for( i = 1 ; i < CountMItems( MenuDriver); i++)
  586.                 {
  587.                     Str255    str;
  588.                     long    r;
  589.                     
  590.                     GetMenuItemText( MenuDriver, i+1, str);
  591.                     
  592.                     str[ 0] -= 3;    StringToNum( str, &r);    str[ 0] += 3;
  593.                     
  594.                     if( r == MADDriver->DriverSettings.ReverbSize) startitem = i+1;
  595.                 }
  596.             }
  597.             else startitem = 1;
  598.         break;
  599.         
  600.         case 169:
  601.             startitem = 2;
  602.             for( i = 0 ; i < CountMItems( MenuDriver); i++)
  603.             {
  604.                 Str255    str;
  605.                 long    r;
  606.                 
  607.                 GetMenuItemText( MenuDriver, i+1, str);
  608.                 
  609.                 str[ 0] -= 2;    StringToNum( str, &r);    str[ 0] += 2;
  610.                 
  611.                 if( r == MADDriver->DriverSettings.ReverbStrength) startitem = i+1;
  612.             }
  613.         break;
  614.         
  615.         case 131:
  616.             if( !has16Bit) { DisableItem( MenuDriver, 3);}
  617.             
  618.             switch( MADDriver->DriverSettings.outPutRate)
  619.             {
  620.                 default:
  621.                 case rate11khz:        startitem = 1;    break;
  622.                 case rate22khz:        startitem = 2;    break;
  623.                 case rate44khz:        startitem = 3;    break;
  624.             }
  625.         break;
  626.         
  627.         case 132:
  628.             if( !Stereo) { DisableItem( MenuDriver, 2);        DisableItem( MenuDriver, 3);}
  629.             
  630.             switch( MADDriver->DriverSettings.outPutMode)
  631.             {
  632.                 default:
  633.                 case MonoOutPut:            startitem = 1;    break;
  634.                 case StereoOutPut:            startitem = 2;    break;
  635.                 case DeluxeStereoOutPut:    startitem = 3;    break;
  636.             }
  637.         break;
  638.         
  639.         case 133:
  640.             if( !has16Bit) { DisableItem( MenuDriver, 2); }
  641.             
  642.             switch( MADDriver->DriverSettings.outPutBits)
  643.             {
  644.                 default:
  645.                 case 8:            startitem = 1;            break;
  646.                 case 16:        startitem = 2;            break;
  647.             }
  648.         break;
  649.     }
  650.     mresult = PopUpMenuSelect(    MenuDriver,
  651.                                 Zone.v,
  652.                                 Zone.h,
  653.                                 startitem);
  654.     ApFontID = i;
  655.     
  656.     if( HiWord( mresult) != 0)
  657.     {
  658.         Boolean    IsPlaying;
  659.         long    speedCopy;
  660.     
  661.         IsPlaying = MADDriver->Reading;
  662.         if( IsPlaying) speedCopy = MADDriver->speed;
  663.         MADDriver->Reading = false;
  664.     
  665.         if( MADStopDriver() != noErr)             ExitToShell();
  666.         if( MADDisposeDriver() != noErr)     ExitToShell();
  667.     
  668.         switch( whichMenu)
  669.         {
  670.             case 131:
  671.                 switch( LoWord( mresult))
  672.                 {
  673.                     default:
  674.                     case 1:    MADDriver->DriverSettings.outPutRate = rate11khz;    break;
  675.                     case 2:    MADDriver->DriverSettings.outPutRate = rate22khz;    break;
  676.                     case 3:    MADDriver->DriverSettings.outPutRate = rate44khz;    break;
  677.                 }
  678.             break;
  679.             
  680.             case 132:
  681.                 switch( LoWord( mresult))
  682.                 {
  683.                     default:
  684.                     case 1:    MADDriver->DriverSettings.outPutMode = MonoOutPut;            break;
  685.                     case 2: MADDriver->DriverSettings.outPutMode = StereoOutPut;        break;
  686.                     case 3: MADDriver->DriverSettings.outPutMode = DeluxeStereoOutPut;    break;
  687.                 }
  688.             break;
  689.             
  690.             case 133:
  691.                 switch( LoWord( mresult))
  692.                 {
  693.                     default:
  694.                     case 1:        MADDriver->DriverSettings.outPutBits = 8;    break;
  695.                     case 2:        MADDriver->DriverSettings.outPutBits = 16;    break;
  696.                 }
  697.             break;
  698.             
  699.             case 128:
  700.                 switch( LoWord( mresult))
  701.                 {
  702.                     default:
  703.                     case 1:        MADDriver->DriverSettings.surround = false;    break;
  704.                     case 2:        MADDriver->DriverSettings.surround = true;    break;
  705.                 }
  706.             break;
  707.             
  708.             case 129:
  709.                 switch( LoWord( mresult))
  710.                 {
  711.                     default:
  712.                     case 1:        MADDriver->DriverSettings.Interpolation = false;    break;
  713.                     case 2:        MADDriver->DriverSettings.Interpolation = true;        break;
  714.                 }
  715.             break;
  716.             
  717.             case 130:
  718.                 switch( LoWord( mresult))
  719.                 {
  720.                     default:
  721.                     case 1:        MADDriver->DriverSettings.TickRemover = false;    break;
  722.                     case 2:        MADDriver->DriverSettings.TickRemover = true;    break;
  723.                 }
  724.             break;
  725.             
  726.             case 165:
  727.                 if( LoWord( mresult) == 1)
  728.                 {
  729.                     MADDriver->DriverSettings.MicroDelay = false;
  730.                 }
  731.                 else
  732.                 {
  733.                     MADDriver->DriverSettings.MicroDelay = true;
  734.                     
  735.                     GetMenuItemText( MenuDriver, LoWord( mresult), str);
  736.                     str[ 0] -= 3;
  737.                     StringToNum( str, &r);
  738.                     str[ 0] += 3;
  739.                     
  740.                     if( r >= 0 && r <= 1000) MADDriver->DriverSettings.MicroDelaySize = r;
  741.                 }
  742.             break;
  743.             
  744.             case 170:
  745.                 if( LoWord( mresult) == 1)
  746.                 {
  747.                     MADDriver->DriverSettings.Reverb = false;
  748.                 }
  749.                 else
  750.                 {
  751.                     MADDriver->DriverSettings.Reverb = true;
  752.                     
  753.                     GetMenuItemText( MenuDriver, LoWord( mresult), str);
  754.                     str[ 0] -= 3;
  755.                     StringToNum( str, &r);
  756.                     str[ 0] += 3;
  757.                     
  758.                     if( r >= 0 && r <= 1000) MADDriver->DriverSettings.ReverbSize = r;
  759.                 }
  760.             break;
  761.             
  762.             case 169:
  763.                 GetMenuItemText( MenuDriver, LoWord( mresult), str);
  764.                 str[ 0] -= 2;
  765.                 StringToNum( str, &r);
  766.                 str[ 0] += 2;
  767.                 
  768.                 if( r >= 0 && r <= 1000) MADDriver->DriverSettings.ReverbStrength = r;
  769.             break;
  770.             
  771.             
  772.         }
  773.         if( MADCreateDriver( &MADDriver->DriverSettings)  != noErr) ExitToShell();
  774.         
  775.         InitDriverString();
  776.         
  777.         MADStartDriver();
  778.         
  779.         if( IsPlaying)
  780.         {
  781.             MADDriver->speed = speedCopy;
  782.             MADDriver->Reading = true;
  783.         }
  784.         DeleteMenu( (*MenuDriver)->menuID);
  785.         return 0;
  786.     }
  787.     else
  788.     {
  789.         DeleteMenu( (*MenuDriver)->menuID);
  790.         return -1;
  791.     }
  792. }
  793.  
  794. void SwitchDriverTo2()
  795. {
  796. Boolean         IsPlaying;
  797. long        speedCopy;        
  798.  
  799.     IsPlaying = MADDriver->Reading;
  800.     if( IsPlaying) speedCopy = MADDriver->speed;
  801.     MADDriver->Reading = false;
  802.     
  803.     if( MADStopDriver() != noErr)             ExitToShell();
  804.     if( MADDisposeDriver() != noErr)     ExitToShell();
  805.     
  806.     
  807.     if( MADCreateDriver( &MADDriver->DriverSettings)  != noErr) ExitToShell();
  808.     
  809.     MADStartDriver();
  810.     
  811.     if( IsPlaying)
  812.     {
  813.         MADDriver->speed = speedCopy;
  814.         MADDriver->Reading = true;
  815.     }
  816. }
  817.  
  818. long    oldTempL;
  819.  
  820. void DrawTimeBar()
  821. {
  822.     Rect           itemRect;
  823.      long        tempL;
  824.      long        fullTime, curTime;
  825.     short        itemType, i;
  826.     Handle        itemHandle;
  827.     Str255        aStr;
  828.     
  829.     GetDialogItem( myDialog, 4, &itemType, &itemHandle, &itemRect);
  830.     
  831.     MADGetMusicStatus( &fullTime, &curTime);
  832.     
  833.     tempL = ((long) (itemRect.right - itemRect.left) * curTime) / fullTime;
  834.     
  835.     if( tempL != oldTempL)
  836.     {
  837.         oldTempL = tempL;
  838.             
  839.         
  840.         i = itemRect.right;
  841.         itemRect.right = itemRect.left + tempL;
  842.         if( itemRect.right > i) itemRect.right = i;
  843.         
  844.         ForeColor( blackColor);
  845.         PaintRect( &itemRect);
  846.         
  847.         itemRect.left = itemRect.right;
  848.         itemRect.right = i;
  849.         
  850.         ForeColor( whiteColor);                            
  851.         PaintRect( &itemRect);
  852.         ForeColor( blackColor);
  853.         
  854.         /**/
  855.         
  856.         GetDialogItem (myDialog, 4, &itemType, &itemHandle, &itemRect);
  857.         MoveTo( itemRect.left + 2, itemRect.bottom - 1);
  858.         TextMode( srcXor);
  859.         if( tempL > 100) tempL = 100;
  860.         NumToString( tempL, aStr);    pStrcat( aStr, "\p %");
  861.         DrawString( aStr);
  862.         TextMode( srcCopy);
  863.         
  864.         /**/
  865.         
  866.         ForeColor( blackColor);
  867.     }
  868. }
  869.  
  870. void MegaLoop()
  871. {
  872. char            theChar;
  873. EventRecord        theEvent;
  874. short            thePart, whichItem, oldH = 0;
  875. WindowPtr        whichWindow;
  876. short            itemType, temp;
  877. Rect            itemRect;
  878. Handle            itemHandle;
  879. DialogPtr        whichDialog;
  880. Point            Location, myPt;
  881. GrafPtr            savePort;
  882. Str255            aStr;
  883.  
  884.     do
  885.     {
  886.         WaitNextEvent( everyEvent, &theEvent, 60L, 0L);
  887.         
  888.         if( theEvent.what == nullEvent)
  889.         {
  890.             GetPort( &savePort);
  891.             SetPort( myDialog);
  892.             
  893.             DrawTimeBar();
  894.             
  895.             SetCursor( &qd.arrow);
  896.             
  897.             SetPort( savePort);
  898.         }
  899.         else if( theEvent.what == mouseDown)
  900.         {
  901.             switch( thePart = FindWindow( theEvent.where, &whichWindow))
  902.             {
  903.                 case inContent:
  904.                     if( DialogSelect( &theEvent, &whichDialog, &whichItem ))
  905.                     {
  906.                         GetPort( &savePort);
  907.                         SetPort( whichDialog);
  908.  
  909.                         switch( whichItem)
  910.                         {
  911.                             case 2:
  912.                                 do
  913.                                 {
  914.                                     GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
  915.                                     GetMouse( &Location);
  916.                     
  917.                                     if( oldH != Location.h)
  918.                                     {
  919.                                         oldH = Location.h;
  920.                     
  921.                                         if( Location.h < itemRect.left)         Location.h = itemRect.left;
  922.                                         else if ( Location.h > itemRect.right)    Location.h = itemRect.right;
  923.                     
  924.                                         VolumeH = Location.h - itemRect.left;
  925.                                         itemRect.right = Location.h;
  926.                                         PaintRect( &itemRect);
  927.                                         GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
  928.                                         itemRect.left = Location.h;
  929.                     
  930.                                         ForeColor( whiteColor);                            
  931.                                         PaintRect( &itemRect);
  932.                                         ForeColor( blackColor);
  933.                                         
  934.                                         /**/
  935.                                         
  936.                                         GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
  937.                                         MoveTo( itemRect.left + 2, itemRect.bottom - 1);
  938.                                         TextMode( srcXor);
  939.                                         NumToString( VolumeH, aStr);    pStrcat( aStr, "\p %");
  940.                                         DrawString( aStr);
  941.                                         TextMode( srcCopy);
  942.                                         
  943.                                         /**/
  944.                                         
  945.                                         GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
  946.                     
  947.                                         SKVolume( 1 + (8 * (Location.h - itemRect.left) / (itemRect.right - itemRect.left)));
  948.                                     }
  949.                                 }while( Button());
  950.                             break;
  951.  
  952.                             case 18:
  953.                                 do
  954.                                 {
  955.                                     GetDialogItem (whichDialog, 18, &itemType, &itemHandle, &itemRect);
  956.                                     GetMouse( &Location);
  957.                     
  958.                                     if( oldH != Location.h)
  959.                                     {
  960.                                         oldH = Location.h;
  961.                     
  962.                                         if( Location.h < itemRect.left)         Location.h = itemRect.left;
  963.                                         else if ( Location.h > itemRect.right)    Location.h = itemRect.right;
  964.                     
  965.                                         SpeedH = Location.h - itemRect.left;
  966.                                         itemRect.right = Location.h;
  967.                                         PaintRect( &itemRect);
  968.                                         GetDialogItem (whichDialog, 18, &itemType, &itemHandle, &itemRect);
  969.                                         itemRect.left = Location.h;
  970.                                         
  971.                                         ForeColor( whiteColor);                            
  972.                                         PaintRect( &itemRect);
  973.                                         ForeColor( blackColor);
  974.                                         
  975.                                         /**/
  976.                                         
  977.                                         GetDialogItem (whichDialog, 18, &itemType, &itemHandle, &itemRect);
  978.                                         MoveTo( itemRect.left + 2, itemRect.bottom - 1);
  979.                                         TextMode( srcXor);
  980.                                         NumToString( SpeedH*2, aStr);        pStrcat( aStr, "\p %");
  981.                                         DrawString( aStr);
  982.                                         TextMode( srcCopy);
  983.                                         
  984.                                         /**/
  985.                                         
  986.                                         GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
  987.                     
  988.                                         MADDriver->VExt = (160 * (Location.h - itemRect.left)) / (itemRect.right - itemRect.left);
  989.                                         if( MADDriver->VExt <= 0) MADDriver->VExt = 1;
  990.                                     }
  991.                                 }while( Button());
  992.                             break;
  993.  
  994.  
  995.                             case 4:
  996.                                 temp = -1;
  997.                                 do
  998.                                 {
  999.                                     GetDialogItem( whichDialog , 4, &itemType, &itemHandle, &itemRect);
  1000.                                     GetMouse( &myPt);
  1001.                                 
  1002.                                     if( temp != myPt.h)
  1003.                                     {
  1004.                                         if( myPt.h < itemRect.left)         myPt.h = itemRect.left;
  1005.                                         else if ( myPt.h > itemRect.right)    myPt.h = itemRect.right;
  1006.                                         
  1007.                                         MADSetMusicStatus( itemRect.left, itemRect.right, myPt.h);
  1008.                                         
  1009.                                         DrawTimeBar();
  1010.                                         
  1011.                                         temp = myPt.h;
  1012.                                     }
  1013.                                 }while( Button());
  1014.                             break;
  1015.                             
  1016.                             case 21:    PressTypeMenu( 129, whichItem);    break;
  1017.                             case 23:    PressTypeMenu( 128, whichItem);    break;
  1018.                             case 30:    PressTypeMenu( 130, whichItem);    break;
  1019.                             case 8:        PressTypeMenu( 165, whichItem);    break;
  1020.                             case 25:    PressTypeMenu( 170, whichItem);    break;
  1021.                             case 28:    PressTypeMenu( 169, whichItem);    break;
  1022.                             case 11:    PressTypeMenu( 131, whichItem);    break;
  1023.                             case 14:    PressTypeMenu( 132, whichItem);    break;
  1024.                             case 17:    PressTypeMenu( 133, whichItem);    break;
  1025.                         }
  1026.                         
  1027.                         SetPort( savePort);
  1028.                     }
  1029.                 break;
  1030.             
  1031.                 case inGoAway:
  1032.                     if( TrackGoAway( whichWindow, theEvent.where)) OnTourne = false;
  1033.                 break;
  1034.                 
  1035.                 case inDrag:
  1036.                     DragWindow( whichWindow, theEvent.where, &qd.screenBits.bounds);
  1037.                 break;
  1038.                 
  1039.                 case inSysWindow:
  1040.                     SystemClick( &theEvent, whichWindow);
  1041.                 break;
  1042.                 
  1043.                 case inZoomIn:
  1044.                 case inZoomOut:
  1045.                     if( TrackBox( whichWindow, theEvent.where, thePart))
  1046.                     {
  1047.                         if( whichWindow->portRect.bottom > 43) SizeWindow( whichWindow, whichWindow->portRect.right, 43, true);
  1048.                         else SizeWindow( whichWindow, whichWindow->portRect.right, 153, true); 
  1049.                     }
  1050.                 break;
  1051.             }
  1052.         }
  1053.         else if( theEvent.what == updateEvt)
  1054.         {
  1055.             BeginUpdate( myDialog);
  1056.             DrawDialog( myDialog);
  1057.             SetPort( myDialog);
  1058.  
  1059.             /*** Volume ***/
  1060.             GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
  1061.             itemRect.left-=1;        //itemRect.right+=1;
  1062.             itemRect.top-=1;        //itemRect.bottom+=1;
  1063.             FrameRectRelief( &itemRect);
  1064.  
  1065.             GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
  1066.             Location.h = VolumeH + itemRect.left;
  1067.             itemRect.right = Location.h;
  1068.             PaintRect( &itemRect);
  1069.             GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
  1070.             itemRect.left = Location.h;
  1071.         
  1072.             ForeColor( whiteColor);                            
  1073.             PaintRect( &itemRect);
  1074.             ForeColor( blackColor);
  1075.             
  1076.             /**/
  1077.             
  1078.             GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
  1079.             MoveTo( itemRect.left + 2, itemRect.bottom - 1);
  1080.             TextMode( srcXor);
  1081.             NumToString( VolumeH, aStr);    pStrcat( aStr, "\p %");
  1082.             DrawString( aStr);
  1083.             TextMode( srcCopy);
  1084.             
  1085.             /**/
  1086.             /*****/
  1087.  
  1088.             /*** Speed **/
  1089.             
  1090.             GetDialogItem (myDialog, 18, &itemType, &itemHandle, &itemRect);
  1091.             itemRect.left-=1;        //itemRect.right+=1;
  1092.             itemRect.top-=1;        //itemRect.bottom+=1;
  1093.             FrameRectRelief( &itemRect);
  1094.  
  1095.             GetDialogItem (myDialog, 18, &itemType, &itemHandle, &itemRect);
  1096.             Location.h = SpeedH + itemRect.left;
  1097.             itemRect.right = Location.h;
  1098.             PaintRect( &itemRect);
  1099.             GetDialogItem (myDialog, 18, &itemType, &itemHandle, &itemRect);
  1100.             itemRect.left = Location.h;
  1101.         
  1102.             ForeColor( whiteColor);                            
  1103.             PaintRect( &itemRect);
  1104.             ForeColor( blackColor);
  1105.             
  1106.             /**/
  1107.             
  1108.             GetDialogItem (myDialog, 18, &itemType, &itemHandle, &itemRect);
  1109.             MoveTo( itemRect.left + 2, itemRect.bottom - 1);
  1110.             TextMode( srcXor);
  1111.             NumToString( SpeedH*2, aStr);        pStrcat( aStr, "\p %");
  1112.             DrawString( aStr);
  1113.             TextMode( srcCopy);
  1114.             
  1115.             /**/
  1116.  
  1117.             /*** Position ***/
  1118.             GetDialogItem (myDialog, 4, &itemType, &itemHandle, &itemRect);
  1119.             itemRect.left-=1;        //itemRect.right+=1;
  1120.             itemRect.top-=1;        //itemRect.bottom+=1;
  1121.             FrameRectRelief( &itemRect);
  1122.  
  1123.             DrawTimeBar();
  1124.             /*****/
  1125.  
  1126.  
  1127.             EndUpdate( myDialog);
  1128.         }
  1129.         else if( theEvent.what == keyDown)
  1130.         {
  1131.             theChar=theEvent.message & charCodeMask;
  1132.             
  1133.             if ((theEvent.modifiers & cmdKey) !=0)
  1134.             {
  1135.                 if( theChar =='Q' ||
  1136.                     theChar =='q' ||
  1137.                     theChar == 'w' ||
  1138.                     theChar == 'W' ||
  1139.                     theChar =='f' ||
  1140.                     theChar == 'F')
  1141.                     
  1142.                     OnTourne = false;
  1143.             }
  1144.         }
  1145.         else if( theEvent.what == kHighLevelEvent) AEProcessAppleEvent (&theEvent);
  1146.     }while( OnTourne == true);
  1147. }
  1148.  
  1149. extern    Boolean        Reading;
  1150.  
  1151. void MusiqueDriverInit(void)
  1152. {
  1153. OSErr                iErr;
  1154. MADDriverSettings    init;
  1155.  
  1156. init.numChn            = 4;
  1157. init.outPutBits        = thePrefs.outPutBits;
  1158. init.outPutRate        = thePrefs.outPutRate;
  1159. init.outPutMode        = thePrefs.outPutMode;
  1160. init.driverMode        = thePrefs.driverMode;
  1161. init.antiAliasing    = thePrefs.antiAliasing;
  1162. init.sysMemory        = true;
  1163. init.repeatMusic     = true;
  1164. init.surround        = thePrefs.surround;
  1165. init.Interpolation    = thePrefs.Interpolation;
  1166. init.MicroDelay        = thePrefs.MicroDelay;
  1167. init.MicroDelaySize    = thePrefs.MicroDelaySize;
  1168. init.Reverb            = thePrefs.Reverb;
  1169. init.ReverbSize        = thePrefs.ReverbSize;
  1170. init.ReverbStrength    = thePrefs.ReverbStrength;
  1171. init.TickRemover    = thePrefs.TickRemover;
  1172.  
  1173. if( init.driverMode == ASCSoundDriver || init.driverMode == AWACSoundDriver)
  1174.     init.driverMode = SoundManagerDriver;
  1175.  
  1176. iErr = MADCreateDriver( &init);
  1177. if( iErr) MyDebugStr( "\pMusicDriver ERROR !");
  1178. }
  1179.  
  1180. void DoPreferences2()
  1181. {
  1182.     OSErr            iErr;
  1183.     short            vRefNum, fRefNum, SvRefNum;
  1184.     long            DirID, inOutBytes, SdirID;
  1185.     Boolean            initOK;
  1186.  
  1187.     HGetVol( 0L, &SvRefNum,&SdirID);
  1188.     
  1189.     initOK = false;
  1190.     
  1191.     iErr = FindFolder( kOnSystemDisk, kPreferencesFolderType, kCreateFolder, &vRefNum, &DirID);
  1192.     
  1193.     iErr = HSetVol( 0L, vRefNum, DirID);
  1194.     
  1195.     iErr = FSOpen( PLAYERPREF, 0, &fRefNum);
  1196.     if( iErr == noErr)
  1197.     {
  1198.         inOutBytes = sizeof( Prefs);
  1199.         iErr = FSRead( fRefNum, &inOutBytes, &thePrefs);
  1200.         iErr = FSClose( fRefNum);
  1201.     
  1202.         if( thePrefs.Version != VERSION)
  1203.         {
  1204.             
  1205.         }
  1206.         else
  1207.         {
  1208.             MusiqueDriverInit();
  1209.             initOK = true;
  1210.         }
  1211.     }
  1212.     
  1213.     if( initOK == false)
  1214.     {
  1215.         OSErr                iErr;
  1216.         MADDriverSettings    init;
  1217.         
  1218.         init.numChn            = 4;
  1219.         init.outPutBits        = 8;
  1220.         init.outPutRate        = rate22khz;
  1221.         init.outPutMode        = MonoOutPut;
  1222.         init.driverMode        = SoundManagerDriver;
  1223.         init.antiAliasing    = false;
  1224.         init.sysMemory        = true;
  1225.         init.repeatMusic     = true;
  1226.         init.surround        = true;
  1227.         init.Interpolation    = true;
  1228.         init.MicroDelay        = false;
  1229.         init.MicroDelaySize    = 0;
  1230.         init.Reverb            = false;
  1231.         init.ReverbSize        = 0;
  1232.         init.ReverbStrength    = 0;
  1233.         init.TickRemover    = false;
  1234.         
  1235.         iErr = MADCreateDriver( &init);
  1236.         if( iErr) MyDebugStr( "\pMusicDriver ERROR !");
  1237.     }
  1238.     
  1239.     HSetVol( 0L, SvRefNum, SdirID);
  1240. }
  1241.  
  1242. void main()
  1243. {
  1244. long            gestaltAnswer;
  1245. int                myBit, OldVol;
  1246. short            itemType;
  1247. Rect            itemRect;
  1248. Handle            itemHandle;
  1249. Point            Svolume;
  1250.  
  1251.  
  1252. InitGraf( &qd.thePort);
  1253. InitFonts();
  1254. FlushEvents(everyEvent,0);
  1255. InitWindows();
  1256. TEInit();
  1257. InitMenus();
  1258. InitCursor();
  1259. MaxApplZone();
  1260.  
  1261. oldTempL = -100;
  1262. OnTourne = true;
  1263. MADInitLibrary("Plugs", true);
  1264. MADDriver = MADGetMADDriverPtr();
  1265.  
  1266. workPixPat = GetPixPat( 130);
  1267.  
  1268. InstallAE();
  1269.  
  1270. myDialog = GetNewDialog( 3214,0L, (WindowPtr)  -1L);
  1271. SizeWindow( myDialog, myDialog->portRect.right, 43, true);
  1272. ShowWindow( myDialog);
  1273. SetPort( myDialog);
  1274. TextFont( geneva);
  1275. TextSize( 9);
  1276.  
  1277. GetDialogItem ( myDialog, 1, &itemType, &itemHandle, &itemRect);
  1278.  
  1279. Gestalt( gestaltSoundAttr, &gestaltAnswer);
  1280. myBit = gestaltStereoCapability;
  1281. Stereo = BitTst( &gestaltAnswer, 31-myBit);
  1282.  
  1283. myBit = gestalt16BitSoundIO;
  1284. has16Bit = BitTst( &gestaltAnswer, 31-myBit);
  1285.  
  1286. NewSoundManager = true;
  1287.  
  1288. if( NewSoundManager)
  1289. {
  1290.     GetDefaultOutputVolume( (long*) &Svolume);
  1291.     Svolume.h /= 32;
  1292.     OldVol = Svolume.h - 1;
  1293. }
  1294. else
  1295. {
  1296.     GetSoundVol((void *)&OldVol);
  1297. }
  1298. GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
  1299. VolumeH     = (OldVol + 1)*( itemRect.right - itemRect.left) / 8;
  1300. SpeedH         = 50;
  1301.  
  1302. SetWTitle( myDialog, LMGetCurApName());
  1303.  
  1304. DoPreferences2();
  1305.  
  1306. InitDriverString();
  1307.  
  1308. if( MADLoadMusicRsrc( 'MADH', 3214) != noErr)
  1309. {
  1310.     ExitToShell();
  1311. }
  1312.  
  1313. #ifndef THINK_C
  1314. MyTrackingUPP = NewDragTrackingHandlerProc( MyTrackingTools);
  1315. MyReceiveUPP = NewDragReceiveHandlerProc( MyReceiveTools);
  1316.         
  1317. InstallTrackingHandler( (DragTrackingHandler) MyTrackingUPP, myDialog, (void *) 0L);
  1318. InstallReceiveHandler( (DragReceiveHandler) MyReceiveUPP, myDialog, (void *) 0L);
  1319. #endif
  1320.  
  1321.  
  1322. /* Music is turn ON !! */
  1323.  
  1324. MADStartDriver();
  1325. MADDriver->Reading = true;
  1326.  
  1327. MegaLoop();
  1328.  
  1329. SetUpSize();
  1330.  
  1331. MADStopDriver();
  1332. MADDisposeMusic();
  1333. MADDisposeDriver();
  1334. MADDisposeLibrary();
  1335.  
  1336. FlushEvents( everyEvent, 0);
  1337. ExitToShell();
  1338. }
  1339.  
  1340.